//
//  DrugViewController.m
//  WE
//
//  Created by apple on 15/11/23.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "DrugViewController.h"
#import "ToolUtil.h"
#import "Size.h"
#import "DrugTableViewCell.h"
#import "DrugDetailViewController.h"

@interface DrugViewController ()<UITableViewDelegate, UITableViewDataSource>
{
    UIButton *closeButton;
}
@end

@implementation DrugViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"相关药品";
    
    [ToolUtil createVerticalLine:10 superView:self.navigationController.navigationBar lift:44 height:24];
    closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    closeButton.frame = CGRectMake(64, 10, 30, 20);
    
    closeButton.titleLabel.font = FONT(14);
    [closeButton setTitle:@"关闭" forState:UIControlStateNormal];
    [closeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [closeButton addTarget:self action:@selector(pressCloseButton) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationController.navigationBar addSubview:closeButton];
    
    UITableView *tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WindowWidth, WindowHeight)];
    tabView.delegate = self;
    tabView.dataSource = self;
    [self.view addSubview:tabView];
}

- (void)viewWillDisappear:(BOOL)animated{
    [closeButton removeFromSuperview];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellString = @"DrugTableViewCell";
    DrugTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellString];
    if (!cell) {
        cell = [[DrugTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellString];
        
    }
    
    return cell;
    
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.navigationController pushViewController:[[DrugDetailViewController alloc] init] animated:YES];
    
}

- (void)pressCloseButton{
    
    [self.navigationController popToRootViewControllerAnimated:YES];
    
    //self.tabBarController.selectedIndex = 0;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
